<script>
  import config from './config'
  import store from '@/store'
  import { getToken } from '@/utils/auth'

  export default {
    onLaunch: function() {
      this.initApp()
    },
    methods: {
      // 初始化应用
      initApp() {
        // 初始化应用配置
        this.initConfig()
        // 检查用户登录状态
        //#ifdef H5
        this.checkLogin()
        //#endif
      },
      initConfig() {
        this.globalData.config = config
      },
      checkLogin() {
        if (!getToken()) {
          this.$tab.reLaunch('/pages/login') 
        }
      }
    }
  }
</script>

<style lang="scss">
  @import '@/static/scss/index.scss';
  
  Page {
      background: $background-color;
      font-size: 28rpx;
      color: $black1;
  }
  
  .input-placeholder,
  .textarea-placeholder {
      color: $placeholder-color;
  }
  
  .iconfont {
      line-height: 1;
      font-size: 28rpx;
  }
  
  .app-btn {
      height: 80rpx;
      line-height: 80rpx;
      border-radius: 16rpx;
      text-align: center;
      background: $theme-color;
      margin: 40rpx 20rpx 80rpx;
      font-weight: bold;
      color: #FFFFFF;
  
      &--disabled {
          background: $disabled;
      }
  }
  
  .app-btn::after {
      display: none;
  }
  
  .app-btn.hover {
      background-color: $theme-color--active;
  }
  
  .app-title {
      margin: 40rpx 26rpx 0;
      font-weight: bold;
      color: $black3;
  }
  
  .app-delete {
      color: $red;
  
      text {
          vertical-align: middle;
      }
  
      .iconfont {
          margin-right: 4rpx;
      }
  
      .text {
          font-size: 24rpx;
      }
  }
  
  .app-empty {
      text-align: center;
      padding: 30rpx 0;
      background: #ffffff;
      border-radius: 16rpx;
      margin: 20rpx;
  
      .plus {
          font-size: 56rpx;
          color: $black3;
          margin-bottom: 20rpx;
      }
  
      .info {
          color: $black3;
      }
  }
  
  .app-navbar-line {
      @include border-top($color: $line-color);
      position: fixed;
      top: 0;
      right: 0;
      left: 0;
      z-index: 99999;
  }
  
  .app-search-wrap {
      position: fixed;
      left: 0;
      top: 0;
      right: 0;
      background-color: #ffffff;
      z-index: 9999;
  
      &.shadow {
          box-shadow: 0 4rpx 24rpx rgba(100, 101, 102, .12);
      }
  
      display: flex;
      align-items: center;
  
      .bd {
          flex: 1;
      }
  
      .ft {
          padding-right: 20rpx;
          min-width: 120rpx;
          height: 100rpx;
          font-size: 24rpx;
          display: flex;
          align-items: center;
          justify-content: flex-end;
  
          &.cur {
              color: $theme-color;
  
              .iconfont {
                  color: $theme-color;
                  transform: rotate(-180deg);
              }
          }
  
          .iconfont {
              margin-left: 10rpx;
              font-size: 24rpx;
              color: #dcdee0;
          }
      }
  
      .menu {
          flex: 1;
          height: 80rpx;
          font-size: 24rpx;
          display: flex;
          align-items: center;
          justify-content: center;
  
          &.cur {
              color: $theme-color;
  
              .iconfont {
                  color: $theme-color;
                  transform: rotate(-180deg);
              }
          }
  
          .iconfont {
              margin-left: 10rpx;
              font-size: 24rpx;
              color: #dcdee0;
          }
      }
  }
  
  .app-bold {
      font-weight: bold !important;
  }
  
  .app-red {
      color: $red !important;
  }
  
  .app-wine {
      color: $wine !important;
  }
  
  .app-purple {
      color: $purple !important;
  }
  
  .app-green {
      color: $green !important;
  }
  
  .app-skyblue {
      color: $skyblue !important;
  }
  
  .app-orange {
      color: $orange !important;
  }
  
  .app-gold {
      color: $gold !important;
  }
  
  .app-blue {
      color: $blue !important;
  }
  
  .app-placeholder {
      color: #c8c8c8;
  }
  
  .app-date-color {
      color: $date-color !important;
  }
  
  .app-gray {
      color: $black3 !important;
  }
  
  .app-placeholder {
      color: $placeholder-color !important;
  }
  
  .app-theme-color {
      color: $theme-color !important;
  }
  
  .app-input {
      @include border($radius: 10rpx, $color: #cccccc);
      border-radius: 10rpx;
      display: flex;
      align-items: center;
      padding: 10rpx 20rpx;
      color: $black1;
      background-color: #fcfcfc;
  
      input {
          width: 100rpx;
      }
  
      .unit {
          margin-left: 10rpx;
      }
  }
</style>
